home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / FindIcon / Get_icon_file_name.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-20  |  1.0 KB  |  35 lines  |  [TEXT/KAHL]

  1. #include "Get_icon_file_name.h"
  2. #include <Folders.h>
  3.  
  4. /*    ------------------------------------------------------------------
  5.     Get_icon_file_name            Get the name of the invisible files
  6.                                 used to store custom icons for folders
  7.                                 and volumes.
  8.     
  9.     This does assume that the name of Finder is "\pFinder".  I am told
  10.     that is true even in foreign systems.
  11.     ------------------------------------------------------------------
  12. */
  13. void    Get_icon_file_name( Str255 icon_file_name )
  14. {
  15.     short    save_resfile, sys_vRefNum, Finder_resfile;
  16.     long    sys_dirID;
  17.     
  18.     save_resfile = CurResFile();
  19.     (void) FindFolder( kOnSystemDisk, kSystemFolderType,
  20.           kDontCreateFolder, &sys_vRefNum, &sys_dirID );
  21.     SetResLoad( false );
  22.     Finder_resfile = HOpenResFile( sys_vRefNum, sys_dirID,
  23.         "\pFinder", fsRdPerm );
  24.     SetResLoad( true );
  25.     if (Finder_resfile != -1)    // successful open
  26.     {
  27.         GetIndString( icon_file_name, 11250, 5 );
  28.         CloseResFile( Finder_resfile );
  29.         UseResFile( save_resfile );
  30.     }
  31.     else
  32.     {
  33.         BlockMove( "\pIcon\r", icon_file_name, 6 );
  34.     }
  35. }